package auction



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Bid)
class BidTests {

    void testNoAmount() {
        Date dateOfBid = new Date()
        Listing bidListing = new Listing(name: "hammer", startingBid: "20.00", endDate: new Date().next())
        Customer customer = new Customer(password: "12345678", emailAddress: "brian@gmail.com")

        Bid bid = new Bid(bidDate: dateOfBid, listing: bidListing, bidder: customer)

        assert !bid.validate() : "Bid with no amount valid."
    }

    void testNoBidDate()
    {
        String bidAmount = "20.00"
        Listing bidListing = new Listing(name: "hammer", startingBid: "20.00", endDate: new Date().next())
        Customer customer = new Customer(password: "12345678", emailAddress: "brian@gmail.com")

        Bid bid = new Bid(amount: bidAmount, listing: bidListing, bidder: customer)

        assert !bid.validate() : "Bid with no bid date valid."
    }

    void testNoBidListing()
    {
        String bidAmount = "20.00"
        Date dateOfBid = new Date()
        Customer customer = new Customer(password: "12345678", emailAddress: "brian@gmail.com")

        Bid bid = new Bid(amount: bidAmount, bidDate: dateOfBid, bidder: customer)

        assert !bid.validate() : "Bid with no listing valid."
    }

    void testNoBidder()
    {
        String bidAmount = "20.00"
        Date dateOfBid = new Date()
        Listing bidListing = new Listing(name: "hammer", startingBid: "20.00", endDate: new Date().next())

        Bid bid = new Bid(amount: bidAmount, bidDate: dateOfBid, listing: bidListing)

        assert !bid.validate() : "Bid with no bidder valid."
    }
}
